package com.trf.fm1;

import java.util.Scanner;

/**
 * @author 小小唐
 * @Date 2022/9/19-星期一-16:15
 *
 *  使用switch结构计算每月的具体天数
 */
public class SwitchDemo {
    public static void main(String[] args) {

        SwitchDemo switchDemo = new SwitchDemo();
        System.out.println("请输入月份：");
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        switchDemo.showDay(i);
    }

    public boolean showDay(int month){
        int day = 0;
        if (month<0){
            System.out.println("同学你见过有负数的月份吗！");
        }else {
        if (month<=12){
            switch (month){
                case 2: day = 28;break;
                case 4: day = 30;break;
                case 6: day = 30;break;
                case 9: day = 30;break;
                case 11: day = 30;break;
                default: day =31;
            }
        }else {
            System.out.println("同学一年只有十二个月！");
        }
        }
        System.out.println(month+"月有"+day+"天");
        return false;
    }
}
